<html>
<head>
<title>APNS推送配置</title> 
{{>/WEB-INF/pages/common/head_refs.part.html}}
<script>
	$(document).ready(function() {
		//聚焦第一个输入框
		$("#appId").focus();
		//为inputForm注册validate函数
		$("#inputForm").validate();
		$(":checkbox._cfg_option").on("change", function(evt){
			var fs=$(evt.target).parents("fieldset")[0];
			$(":input:not(._cfg_option)", fs).attr('disabled', !evt.target.checked);
		});
		$("#inputForm").submit(function(evt){
			var form = $(this);
			if(form.valid()==false){
				evt.preventDefault();
				return false;
			}
			var n=$(":input._cfg_option:checked", form).length;
			if(n==0){
				alert("至少填写一项才能提交");
				evt.preventDefault();
				return false;
			}
			return true;
		});
	});
</script>
</head>
<body>
	<div class="container">
		{{>/WEB-INF/pages/common/layout_header.part.html}}
		<ul class="breadcrumb">
		  <li><a href="{{ctx}}">首页</a> <span class="divider">/</span></li>
		  <li class="active">配置推送渠道</li>
		</ul>
		<form id="inputForm" action="{{ctx}}/push/config/channel" method="post" enctype="multipart/form-data"
			class="form-horizontal">
			<div class="control-group">
				<label for="appId" class="control-label">应用标识:</label>
				<div class="controls">
					<input type="text" id="appId" name="appId" value="{{appId}}" {{^create}}disabled{{/create}}
						class="input-large required"/>
					{{^create}}
					<input type="hidden" name="appId" value="{{appId}}"/>
					{{/create}}
				</div>
			</div>
			{{#apnsForm}}
			<fieldset>
				<legend>
					<label class="checkbox"><input type="checkbox" id="chkbox_apns" class="_cfg_option" checked><h4>APNS生产环境推送配置</h4></label>
				</legend>
				<div class="control-group">
					<label for="certFile" class="control-label">证书文件:</label>
					<div class="controls">
						<input type="file" id="certFile" name="apns.certFile"
							class="input-large" />
					</div>
				</div>
				<div class="control-group">
					<label for="certPassword" class="control-label">证书密码:</label>
					<div class="controls">
						<input type="password" id="certPassword" name="apns.certPassword"
							class="input-large required" />
					</div>
				</div>
				<div class="control-group">
					<label for="certPassword1" class="control-label">再次输入证书密码:</label>
					<div class="controls">
						<input type="password" id="certPassword1" name="certPassword1"
							class="input-large required" />
					</div>
				</div>
			</fieldset>
			{{/apnsForm}}
			{{#apnsSandboxForm}}
			<fieldset id="apns_sandbox">
				<legend>
					<label class="checkbox"><input type="checkbox" id="chkbox_apns_sandbox" class="_cfg_option" checked><h4>APNS Sandobx环境推送配置</h4></label>
				</legend>
				<div class="control-group">
					<label for="certFile" class="control-label">证书文件:</label>
					<div class="controls">
						<input type="file" id="certFile" name="apnsSandbox.certFile"
							class="input-large" />
					</div>
				</div>
				<div class="control-group">
					<label for="certPassword" class="control-label">证书密码:</label>
					<div class="controls">
						<input type="password" id="sandbox_certPassword" name="apnsSandbox.certPassword"
							class="input-large required" />
					</div>
				</div>
				<div class="control-group">
					<label for="certPassword1" class="control-label">再次输入证书密码:</label>
					<div class="controls">
						<input type="password" id="certPassword2" name="certPassword2"
							class="input-large required" />
					</div>
				</div>
			</fieldset>
			{{/apnsSandboxForm}}
			{{#openfireForm}}
			<fieldset>
				<legend>
					<label class="checkbox"><input type="checkbox" id="chkbox_openfire"  class="_cfg_option" checked><h4>Openfire推送配置</h4></label>
				</legend>
				<div class="control-group">
					<label for="username" class="control-label">登录名:</label>
					<div class="controls">
						<input type="text" id="username" name="openfire.username" value="{{openfire.username}}" 
							class="input-large required"/>
					</div>
				</div>
				<div class="control-group">
					<label for="openfirePassword" class="control-label">登录密码:</label>
					<div class="controls">
						<input type="password" id="openfirePassword" name="openfire.password"
							class="input-large required" />
					</div>
				</div>
				<div class="control-group">
					<label for="openfirePassword1" class="control-label">再次输入登录密码:</label>
					<div class="controls">
						<input type="password" id="openfirePassword1" name="openfirePassword1"
							class="input-large required" />
					</div>
				</div>
			</fieldset>
			{{/openfireForm}}
			<div class="form-actions">
				<input id="submit_btn" class="btn btn-primary" type="submit"
					value="提交" />&nbsp; <input id="cancel_btn" class="btn"
					type="button" value="返回" onclick="history.back()" />
			</div>
			<input type="hidden" name="redirect" value="{{redirect}}"/>
		</form>
		{{>/WEB-INF/pages/common/layout_footer.part.html}}
	</div>
</body>
</html>
